
import { Component, OnInit,ViewChild } from '@angular/core';
import { ModalController,NavParams ,Platform } from '@ionic/angular';
import { SignaturePad } from 'angular2-signaturepad/signature-pad';//引入手写板
@Component({
  selector: 'app-popover',
  templateUrl: './popover.component.html',
  styleUrls: ['./popover.component.scss'],
})
export class PopoverComponent  {
  public imgPng:any
  public onTouch:boolean = false
  signatureImage="";
  @ViewChild(SignaturePad, { static: true })  signaturePad: SignaturePad; //第二视图
  public signaturePadOptions: Object = { // passed through to szimek/signature_pad constructor
    'minWidth': 2,
    'canvasWidth': this.Platform.width(),
    'canvasHeight': this.Platform.height()
  };
  constructor(
    public modalController:  ModalController,
    public navParams: NavParams,
    public Platform:Platform
  ) { }


  ngAfterViewInit() {
    debugger
    console.log("ngAfterViewInit")
    this.signaturePad.set('minWidth', 2); // set szimek/signature_pad options at runtime
    this.signaturePad.clear(); // invoke functions from szimek/signature_pad API
  }
 
  drawComplete() {
    this.navParams.data.modal.dismiss({
      result: {
        'msg': this.signaturePad.toDataURL(),
        'info': true
      }
    });
    console.log(this.signaturePad.toDataURL());
  }
 
  drawStart() {
    // will be notified of szimek/signature_pad's onBegin event
    console.log('begin drawing');
  }
  drawClear(){
    this.signaturePad.clear();
  }


}
